package com.example.affair.controller;

import com.example.affair.service.LogService;
import com.example.affair.service.UserSevice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RequestMapping("/propaga")
@RestController
public class PropagationController {
    @Autowired
    private UserSevice userSevice;

    @Autowired
    private LogService logService;
    @Transactional(propagation = Propagation.REQUIRED)
    @RequestMapping("/p1")
    public String p1(String name,String password){
        userSevice.registryUser(name,password);

        Integer sum = logService.intsertLog(name, "用户注册");
        log.info("Log:",sum);
        return "完成";
    }
}
